extends ../layout
block content
	.main-content
		h2 #{title}
			-if(user && user.name == 'name')
				a(href='/getuppaperBook') 新书上传地址[仅管理员可见]
		ul.paperBook
			-for(var index = paperBook.length - 1; index >= 0; --index)
				li
					-if(user && user.name == 'name')
						.btn.delete(paper-id="#{paperBook[index]._id}") ×
					-if(paperBook[index].cover.data == undefined)
						.paperCoverImg
							img.paperCover(src='/images/default/avatar.jpg')
					-else
						.paperCoverImg
							img.paperCover(src='data:#{paperBook[index].cover.contentType};base64,#{paperBook[index].cover.data.toString("base64")}')
					.info
						h3.title
							a(href='/paperbook/#{paperBook[index]._id}') #{paperBook[index].name_zh}
							-if(user && user.name == 'name')
								br
								a(href='/edit/#{paperBook[index]._id}') 修改新书信息[仅管理员可见]
						.author 作者：#{paperBook[index].author}
						.press 出版社：#{paperBook[index].press}
						.releaseTime 出版年：#{paperBook[index].releaseTime}
		script.
			$('.delete').click(function(){
				if(window.confirm('delete?')){
					var bookId = $(this).attr('paper-id'),
					$delete = $(this);
					$.get('/delete/'+bookId,{bookId:bookId},function(data){
						if(data.ok){
							alert('删除成功');
							$delete.parent('li').detach();
						}
					},'json');
				}
			});